#ifndef DYN_ROOTS_SECANTMETHOD_H
#define DYN_ROOTS_SECANTMETHOD_H

#include "../utilities/dyn_functor.h"
#include "dyn_roots.h"

/*! \brief Superlinear convergentn method
 * for 1D root finding.
 *
 * This class implements the secant method
 * for root-finding in 1D. It has superlinear
 * convergence, which is somewhat better
 * than the bisection.
 */

class SecantMethod : public RootFinding
{
public:
    /*! The constructor specifies the function,
     * the starting points, the precision of the root,
     * and the maximum number of iterations to perform.
     */
    SecantMethod(Functor& func,
                 double init,
                 double init2,
                 const double tol,
                 const int Nmax);

    /*! @name Accessor functions.
     * We define specific accessor functions.
     */
    //@{
    double getInitialValue2(){return initialValue2;}

    void setInitialValue2(const double init2){initialValue2 = init2;}
    //@}

    /*! Re-declaration of pure virtual solve() function.*/
    virtual int solve();

protected:
    /*! The secant method requires two initial
     * data points. We declare the second one.
     */
    //@{
    Functor& function;
    double initialValue2;
    //@}
};

#endif // DYN_ROOTS_SECANTMETHOD_H
